package com.lab303.powerproject.repository;

import com.lab303.powerproject.entity.PredictElectricity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

public interface PredictElectricityRepository extends JpaRepository<PredictElectricity,Integer> {
    @Query(nativeQuery = true,value = "select * from predict_dl pd order by pd.date desc limit 1")
    PredictElectricity getPredictElectricityByDate();

    @Query(nativeQuery = true,value = "select * from predict_dl pd where pd.id = ?1 order by pd.date desc limit 1")
    PredictElectricity getPredictElectricityByDateAnId(Integer id);

    @Query(nativeQuery = true,value = "select * from predict_dl pd where DATE_FORMAT(pd.date,'%Y-%m-%d')=?1 and pd.id = ?2")
    PredictElectricity findPredictDlByDateAndId(String day,Integer id);
}
